package com.beverage.lemonade.process;

import org.json.JSONException;
import org.json.JSONObject;

import android.content.Context;
import android.preference.PreferenceManager;

public class ContentJson extends JSONObject {

	protected int CONTENT_ID;
	protected int UPDATE_DATE;
	protected int DATE;
	protected int CONTENT;
	protected double NUMBER;
	protected String MEMO;

	public ContentJson(int CONTENT_ID, int UPDATE_DATE, int DATE, int CONTENT,
			String MEMO, double NUMBER) throws JSONException {
		super();
		this.CONTENT_ID = CONTENT_ID;
		this.UPDATE_DATE = UPDATE_DATE;
		this.DATE = DATE;
		this.CONTENT = CONTENT;
		this.NUMBER = NUMBER;
		if (MEMO == null) {
			this.MEMO = "";
		} else {
			this.MEMO = MEMO;

		}
		setInfo();
	}

	public ContentJson(String json) throws JSONException {
		super(json);
		this.CONTENT_ID = getInt("CONTENT_ID");
		this.UPDATE_DATE = getInt("UPDATE_DATE");
		this.DATE = getInt("DATE");
		this.CONTENT = getInt("CONTENT");
		this.NUMBER = getDouble("NUMBER");
		this.MEMO = getString("MEMO");
	}

	protected void setInfo() {

		try {
			put("CONTENT_ID", String.valueOf(CONTENT_ID));
			put("UPDATE_DATE", String.valueOf(UPDATE_DATE));
			put("DATE", String.valueOf(DATE));
			put("CONTENT", String.valueOf(CONTENT));
			put("MEMO", MEMO);
			put("NUMBER", String.valueOf(NUMBER));
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public void setContent(int CONTENT_ID, int UPDATE_DATE, int DATE,
			int CONTENT, String MEMO, double NUMBER) {

		try {
			put("CONTENT_ID", String.valueOf(CONTENT_ID));
			put("UPDATE_DATE", String.valueOf(UPDATE_DATE));
			put("DATE", String.valueOf(DATE));
			put("CONTENT", String.valueOf(CONTENT));
			put("MEMO", MEMO);
			put("NUMBER", String.valueOf(NUMBER));
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	protected void setContent() {

		try {
			put("CONTENT_ID", CONTENT_ID);
			put("UPDATE_DATE", UPDATE_DATE);
			put("DATE", DATE);
			put("CONTENT", CONTENT);
			put("MEMO", MEMO);
			put("NUMBER", NUMBER);
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public int getCONTENT_ID() {
		return CONTENT_ID;
	}

	public void setCONTENT_ID(int cONTENT_ID) {
		CONTENT_ID = cONTENT_ID;
		setContent();
	}

	public int getUPDATE_DATE() {
		return UPDATE_DATE;
	}

	public void setUPDATE_DATE(int uPDATE_DATE) {
		UPDATE_DATE = uPDATE_DATE;
		setContent();
	}

	public int getDATE() {
		return DATE;
	}

	public void setDATE(int dATE) {
		DATE = dATE;
		setContent();
	}

	public int getCONTENT() {
		return CONTENT;
	}

	public void setCONTENT(int cONTENT) {
		CONTENT = cONTENT;
		setContent();
	}

	public double getNUMBER() {
		return NUMBER;
	}

	public void setNUMBER(double nUMBER) {
		NUMBER = nUMBER;
		setContent();
	}

	public String getMEMO() {
		return MEMO;
	}

	public void setMEMO(String mEMO) {
		MEMO = mEMO;
		setContent();
	}

}
